package com.taritari.journal.rabbitmq;

import com.alibaba.fastjson.JSONObject;
import com.taritari.journal.entity.dto.UserLikeDto;
import com.taritari.journal.services.CommentService;
import com.taritari.journal.services.TreeHoleService;
import org.springframework.amqp.rabbit.annotation.RabbitHandler;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

/**
 * @author taritari
 * @date 2024-01-24 18:07
 * @description 评论喜欢~队列
 */
@Service
@RabbitListener(queues = {"like_comment"}) //队列名
public class LikeCommentConsumer {
    @Autowired
    private CommentService commentService;
    @RabbitHandler
    public void receiveMessage(String message){
        UserLikeDto userLikeDto = JSONObject.parseObject(message, UserLikeDto.class);
        System.out.println("==========================接收消息==========================");
        System.out.println(userLikeDto);
        commentService.userClickLike(userLikeDto.getUserId(),userLikeDto.getCommentId());

    }
}
